import Vue from 'vue'
import App from './App.vue'
import router from './router'
import element from './plugins/element.js'
// 引入全局样式表
import './assets/css/global.css'
//引入icon样式表
import './assets/font/iconfont.css'
//导入vue-table-with-tree-grid
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编译器
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.use(VueQuillEditor)

import axios from 'axios'
//设置axios的默认请求地址
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
Vue.prototype.$http = axios;
// 请求到达服务器之前，先调用use中的这个回调函数来添加请求头信息
axios.interceptors.request.use(config => {
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
})
Vue.config.productionTip = false
    //全局注册vue-table-with-tree-grid组件
Vue.component('tree-table', TreeTable)
    //创建过滤器将秒数过滤为年月日，时分秒
Vue.filter('dateFormat', function(originVal) {
    const dt = new Date(originVal)
    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')